package com.ideaaedi.springcloud.jd.commonspring.sharding;

import com.ideaaedi.springcloud.jd.commonspring.sharding.properties.DatasourceArgs;
import com.ideaaedi.springcloud.jd.commonspring.sharding.properties.RulesShardingProperties;
import com.ideaaedi.springcloud.jd.commonspring.sharding.support.LocalCacheShardingTableSupport;
import com.ideaaedi.springcloud.jd.commonspring.sharding.support.RefreshActualDataNodesSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import javax.annotation.PostConstruct;

/**
 * Sharding自动装配
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img
 * src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 2021.0.5.A
 */
@Slf4j
@Configuration
@ConditionalOnProperty(value = "spring.shardingsphere.enabled", havingValue = "true")
@Import(value = {RulesShardingProperties.class, DatasourceArgs.class,
        LocalCacheShardingTableSupport.class, RefreshActualDataNodesSupport.class})
public class ShardingAutoConfig {
    
    @PostConstruct
    private void tips() {
        log.info("enable shardingsphere.");
    }
}
